<template>
	<view class="message-page">
		<!-- 顶部栏 -->
		<view class="message-header">
			<text class="back-arrow" @click="goBack" @tap="goBack">＜</text>
			<text class="message-title">消息</text>
			<view class="message-actions">
				<text class="dot">•••</text>
			</view>
		</view>
		
		<!-- 搜索栏 -->
		<view class="search-bar">
			<view class="search-input">
				<text class="search-icon">🔍</text>
				<input type="text" placeholder="搜索" />
			</view>
		</view>
		
		<!-- 消息列表 -->
		<view class="message-list">
			<view v-for="(msg, index) in messages" :key="index" class="message-item">
				<image class="avatar" :src="msg.avatar" mode="aspectFill"></image>
				<view class="message-content">
					<view class="message-header">
						<text class="name">{{ msg.name }}</text>
						<text class="time">{{ msg.time }}</text>
					</view>
					<text class="message-text">{{ msg.content }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';

// 示例消息数据
const messages = ref([
	{
		avatar: '/static/avatar1.png',
		name: '系统通知',
		time: '12:30',
		content: '您的订单已完成，欢迎再次光临'
	},
	{
		avatar: '/static/avatar2.png',
		name: '客服中心',
		time: '昨天',
		content: '您好，有什么可以帮您？'
	},
	{
		avatar: '/static/avatar3.png',
		name: '优惠活动',
		time: '周一',
		content: '新用户专享优惠，点击查看详情'
	}
]);

function goBack() {
	uni.navigateBack({
		delta: 1,
		fail: () => {
			uni.switchTab({ url: '/pages/index/index' });
		},
	});
}
</script>

<style>
.message-page {
	background: #f8f8f8;
	min-height: 100vh;
}

.message-header {
	background: linear-gradient(135deg, #2d8cf0 60%, #5bc0eb 100%);
	padding-bottom: 30rpx;
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

.back-arrow {
	position: absolute;
	left: 30rpx;
	top: 60rpx;
	color: #fff;
	font-size: 40rpx;
}

.message-title {
	color: #fff;
	font-size: 36rpx;
	font-weight: bold;
	margin-top: 60rpx;
}

.message-actions {
	position: absolute;
	right: 30rpx;
	top: 60rpx;
	display: flex;
	align-items: center;
	gap: 20rpx;
	color: #fff;
}

.search-bar {
	padding: 20rpx;
	background: #fff;
}

.search-input {
	background: #f5f5f5;
	border-radius: 30rpx;
	padding: 15rpx 30rpx;
	display: flex;
	align-items: center;
}

.search-icon {
	margin-right: 10rpx;
	color: #999;
}

.message-list {
	padding: 20rpx;
}

.message-item {
	display: flex;
	padding: 20rpx;
	background: #fff;
	border-radius: 12rpx;
	margin-bottom: 20rpx;
}

.avatar {
	width: 80rpx;
	height: 80rpx;
	border-radius: 50%;
	margin-right: 20rpx;
}

.message-content {
	flex: 1;
}

.message-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10rpx;
}

.name {
	font-size: 32rpx;
	font-weight: bold;
	color: #333;
}

.time {
	font-size: 24rpx;
	color: #999;
}

.message-text {
	font-size: 28rpx;
	color: #666;
	display: -webkit-box;
	-webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-clamp: 1;
	overflow: hidden;
}
</style>
